function getApiLinks(){
  var apilinks={
    protocol : "https",
    server:"www.fanruohong.cn",
    apis:[
      {
        name:"getSports",
        link:"/PlaygroundBooking/api/playground/sports"},
    {
      name: "getCourts",
      link: "/PlaygroundBooking/api/playground/cours"},
    {
      name: "bookSession",
      link: "/PlaygroundBooking/api/booking/booking"},
    {
      name: "getOpenid",
      link: "/PlaygroundBooking/api/wechat/openid"
    },
    {
      name: "createOrGetUser",
      link: "/PlaygroundBooking/api/user/user"
    },
    {
      name: "readUserByOpenId",
      link: "/PlaygroundBooking/api/user/user"
    }
    ]
  }
  return apilinks;
}

function getApiLink(apiName){
  var apis = getApiLinks().apis;
  var apiLink="";
  for (var i = 0; i < apis.length;i++){
    if(apis[i].name==apiName){
      apiLink=apis[i].link;
    }
  }

  if(apiLink==""){
    console.log("no such api registered : "+apiName);
    return ;
  }

  var url = getApiLinks().protocol + "://" + getApiLinks().server + apiLink;

  return url;
}

module.exports={
  getApiLinks : getApiLinks,
  getApiLink: getApiLink}